home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / sprprcdr.lha / Polygon.AMOS / Polygon.amosSourceCode
AMOS Source Code  |  1996-01-26  |  2KB  |  66 lines

  1. '   ******************************************************** 
  2. '   ***                                                  *** 
  3. '   ***                 Polygon Procedure                *** 
  4. '   ***                                                  *** 
  5. '   ***                        by                        *** 
  6. '   ***                                                  *** 
  7. '   ***                   Joseph Bolin                   *** 
  8. '   ***                                                  *** 
  9. '   ******************************************************** 
  10.  
  11. Screen Open 0,320,200,4,Lowres
  12. Curs Off : Flash Off : Paper 0 : Cls 0
  13. Palette $0,$FFF,$A0A
  14. Ink 1,2
  15. For X=0 To 6
  16.    _POLYGON[X*45+20,25,3,20,20,X*20,1]
  17. Next 
  18. Set Pattern 13
  19. _POLYGON[160,90,20,50,30,25,1]
  20. _POLYGON[50,90,5,30,30,30,0]
  21. For R=0 To 9
  22.    _POLYGON[270,90,3,35,35,R*12,0]
  23. Next 
  24. ML=360/(X+3)/10
  25. For X=0 To 3
  26.    HG=9 : If X and 1 Then HG=4
  27.    For R=0 To HG
  28.       _POLYGON[40+X*80,160,X+3,36,15,R*36,0]
  29.    Next 
  30. Next 
  31.  
  32. Procedure _POLYGON[_XPOS,_YPOS,_POINTS,_WIDTH,_HEIGHT,_ROTATE,_FILLED]
  33.    
  34.    ' Inputs: _XPOS,_YPOS  Center of polygon   
  35.    '         _POINTS      Number of points in polygon   
  36.    '         _WIDTH       Width of polygon  
  37.    '         _HEIGHT      Height of polygon   
  38.    '         _ROTATE      Rotation angle of polygon     
  39.    '         _FILLED      Flag for fill:0=No, 1=Yes   
  40.    '
  41.    ' Output: Draws a regular polygon on the current screen
  42.    '         with the current ink colors and the current pattern
  43.  
  44.    Degree 
  45.    If _POINTS<3
  46.       _POINTS=3
  47.    End If 
  48.    If _POINTS>360
  49.       _POINTS=360
  50.    End If 
  51.    OX=_WIDTH*Cos(_ROTATE)+_XPOS+0.5
  52.    OY=_WIDTH*Sin(_ROTATE)+_YPOS+0.5
  53.    For R=360/_POINTS To 359+360/_POINTS Step 360/_POINTS
  54.       NX#=Cos(R)*_WIDTH
  55.       NY#=Sin(R)*_HEIGHT
  56.       X=NX#*Cos(_ROTATE)-NY#*Sin(_ROTATE)+_XPOS+0.5
  57.       Y=NY#*Cos(_ROTATE)+NX#*Sin(_ROTATE)+_YPOS+0.5
  58.       If _FILLED<>1
  59.          Polyline OX,OY To X,Y
  60.       End If 
  61.       If _FILLED=1
  62.          Polygon _XPOS,_YPOS To OX,OY To X,Y
  63.       End If 
  64.       OX=X : OY=Y
  65.    Next 
  66. End Proc